package com.gxa.controller;

import com.gxa.pojo.*;
import com.gxa.utils.Constants;
import com.gxa.utils.ResponseData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

/**
 * Created with IntelliJ IDEA.
 * User: zxy
 * Date: 2020/11/26 14:48
 * Description:
 * Version: V1.0
 */
@RestController
@RequestMapping("/groupbuylist")
@Api(value = "团购列表",tags = "团购列表")
public class groupBuyingListController {

    @Autowired
    private ResponseData responseData;

    @GetMapping(value = "/queryGroupBuyList")
    @ApiOperation(value = "查询团购列表",notes = "查询团购列表",httpMethod = "GET", response = ResponseData.class)
    public ResponseData queryGroupBuyList(){
        BulkGroup bulkGroup = new BulkGroup();
        bulkGroup.setBulkOid("团购编号");
        bulkGroup.setBulkLider("团长");
        bulkGroup.setGroupPnum(16);
        bulkGroup.setBulkLp(23);
        bulkGroup.setGroupBtime(new Date());
        bulkGroup.setGroupEtime(new Date());
        bulkGroup.setBulkStatus(2);
        Goods goods = new Goods();
        goods.setGoodsName("商品名称");
        bulkGroup.setGoods(goods);
        responseData.setCode(Constants.SUCCESS);
        responseData.setMsg("查询成功");
        responseData.setData(bulkGroup);
        return responseData;
    }

    @GetMapping(value = "/queryGroupBuyListByCode")
    @ApiOperation(value = "按照团购编号查询团购列表",notes = "按照团购编号查询团购列表",httpMethod = "GET", response = ResponseData.class)
    public ResponseData queryGroupBuyListByCode(String bulk_oid){
        BulkGroup bulkGroup = new BulkGroup();
        bulkGroup.setBulkOid("团购编号"+bulk_oid);
        bulkGroup.setBulkLider("团长");
        bulkGroup.setGroupPnum(16);
        bulkGroup.setBulkLp(23);
        bulkGroup.setGroupBtime(new Date());
        bulkGroup.setGroupEtime(new Date());
        bulkGroup.setBulkStatus(1);
        Goods goods = new Goods();
        goods.setGoodsName("商品名称");
        bulkGroup.setGoods(goods);
        responseData.setCode(Constants.SUCCESS);
        responseData.setMsg("查询成功");
        responseData.setData(bulkGroup);
        return responseData;
    }

    @GetMapping(value = "/queryGroupDetails")
    @ApiOperation(value = "查询团购详情",notes = "查询团购详情",httpMethod = "GET", response = ResponseData.class)
    public ResponseData queryGroupDetails(){
        BulkGroup bulkGroup = new BulkGroup();
        bulkGroup.setBulkOid("团购编号");
        bulkGroup.setBulkStatus(1);
        bulkGroup.setBulkUser("购买用户");
        bulkGroup.setBulkBtime(new Date());
        bulkGroup.setBulkEtime(new Date());
        Goods goods = new Goods();
        goods.setGoodsName("商品名称");
        Users users = new Users();
        users.setUserXname("用户昵称");
        users.setUserPhoto("用户头像");
        Order order = new Order();
        order.setOrderCode("订单编号");
        Ordoper ordoper = new Ordoper();
        ordoper.setOrdoperStatu(1);
        ordoper.setDelivStatu(1);
        ordoper.setPayStatu(1);
        order.setOrdoper(ordoper);
        bulkGroup.setGoods(goods);
        bulkGroup.setUsers(users);
        bulkGroup.setOrder(order);
        responseData.setCode(Constants.SUCCESS);
        responseData.setMsg("查询成功");
        responseData.setData(bulkGroup);
        return responseData;
    }
}
